package com.example.mqspring.rabiitmqbasicleverone.rabbitmqDirectRoutkey;

import com.example.mqspring.utils.RabbitMqUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class MainClass {

    private static String myExchangge = "bobo-exchange-direct";
    private static String message = "今天下午2点发工资";
    private static String routingkey = "BOBO_DIRECT_MESSAGE";
    public static void main(String[] args) {
        Connection connection = RabbitMqUtil.createConnection();
        Channel channel = null;
        try {
            channel = connection.createChannel();
            Producer producer = new Producer();
//          发消息
            producer.sendMessage(channel,myExchangge,routingkey,message);
            System.out.println("消息已发送");
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
//                channel.close();
//                connection.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
